<template>
  <div class="daiying">
    <div class="daiying1">
      <p>近期最受期待</p>
      <div class="daiying2">
        <ul class="daiying22">
          <li v-for="item in gundong" :key="item.id">
            <div class="daiying21">{{ item.wish }}人想看</div>
            <img :src="item.img" />
            <div class="daiying3">{{ item.nm }}</div>
            <div class="daiying4">{{ item.comingTitle }}</div>
          </li>
        </ul>
      </div>
    </div>
    <div class="daiying5">
      <ul class="daiying51">
        <li v-for="(value,key) in daiyinglist" :key="key">
          <p>{{key}}</p>
          <ul>
          <li v-for="item in value" class="daiying52" :key="item.id">
            <div class="daiying53">
              <img :src="item.img | formatImg" />
            </div>
            <div class="daiying54">
              <div class="daiying541">{{item.nm}}</div>
              <div class="daiying542">{{item.wish}}人想看</div>
              <div class="daiying543">主演：{{item.star}}</div>
              <div class="daiying544">{{item.rt}}上映</div>
            </div>
            <div class="daiying55">
                <div v-if="item.showst == 4" class="showst4">预售</div>
                <div v-if="item.showst == 1" class="showst1">想看</div>
            </div>
          </li>
        </ul>
          
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import gundong from "@/components/hot/gundong";

export default {
  data() {
    return {
      gundong: [],
      daiyinglist: [],
    };
  },
  name: "wait",
  mounted() {
    axios
      .get(
        "/ajax/mostExpected?ci=30&limit=10&offset=0&token=&optimus_uuid=38C8A010D55911EB8EA841F6113CA2EF324B120B96D64DF680E7AD571B37599C&optimus_risk_level=71&optimus_code=10"
      )
      .then((res) => {
        console.log(res);
        var gundong = res.data.coming;
        gundong.forEach((item) => {
          item.img = item.img.replace("w.h", "85.115");
        });
        gundong.forEach((item) => {
          item.comingTitle = item.comingTitle.split(" ")[0];
        });
        this.gundong = gundong;
      });
    axios
      .get(
        "ajax/comingList?ci=30&token=&limit=10&optimus_uuid=38C8A010D55911EB8EA841F6113CA2EF324B120B96D64DF680E7AD571B37599C&optimus_risk_level=71&optimus_code=10"
      )
      .then((res) => {
        // console.log(res);
        var daiyingList = res.data.coming;
        var daiying = {};
        daiyingList.forEach((item) => {
          if (daiying[item.comingTitle]) {
            daiying[item.comingTitle].push(item);
          } else {
            daiying[item.comingTitle] = [];
            daiying[item.comingTitle].push(item);
          }
        });
        this.daiyinglist = daiying;
        console.log(daiying);
        console.log(this.daiyinglist);
      });
  },
  filters:{
    formatImg(value){
      return  value.replace("w.h", "85.115");
    }
  },
  components: {
    gundong,
  },
};
</script>

<style scoped>
.showst4{
  background: #3c9fe6;
  border-radius:5px;
  color: #fff;
  font-size: 12px;
}
.showst1{
  background: #faaf00;
   border-radius:5px;
   color: #fff;
  font-size: 12px;
}
div {
  box-sizing: border-box;
}
.daiying1 {
  width: 100%;
  height: 216px;
  /* background: gray; */
  margin-top: 156.5px;
  padding-bottom: 12px;
  padding-left: 15px;
  padding-right: 0px;
  padding-top: 12px;
  color: #000;
  border-bottom: 10px solid rgb(245, 240, 240);
}
p {
  margin-bottom: 12px;
}
.daiying2 {
  width: 100%;
  height: 161px;
  /* background: rgb(175, 171, 171); */
  overflow: scroll;
}
.daiying22 {
  width: 950px;
  /* height: 160px; */
  display: flex;
}
.daiying22 li {
  width: 85px;
  height: 157px;
  /* background: gainsboro; */
  margin-right: 10px;
  position: relative;
}
.daiying22 li img {
  width: 85px;
  height: 115px;
}
.daiying3 {
  width: 80px;
  height: 17px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #222222;
  font-weight: bold;
}
.daiying4 {
  font-size: 12px;
  color: #999999;
}
.daiying21 {
  font-size: 12px;
  position: absolute;
  top: 100px;
  /* left: 4px; */
  color: #faaf00;
}
.daiying5 {
  width: 100%;
  height: auto;
  margin-bottom: 60px;
  /* margin-top: 372.5px; */
  /* background: gray; */
}
.daiying5 p{
  width: 345px;
  height: 19px;
  padding: 12px 15px 0;
  font-size: 14px;
}
.daiying5 img{
  width: 64px;
  height: 90px;
}
.daiying52{
  display: flex;
  /* border-bottom:2px solid rgb(235, 225, 225); */
}
.daiying5 .daiying52{
  width: 350px;
  height: 90px;
  margin-left: 15px;
  margin-bottom: 20px;
}

.daiying52 .daiying53{
  width:64px;
  height: 90px;
  /* background: greenyellow; */
}
.daiying52 .daiying54{
  width: 207px;
  height: 90px;
  margin-left: 10px;
  /* background: honeydew; */
}
.daiying52 .daiying55{
  width: 47px;
  height: 27px;
  /* background: #3c9fe6; */
  border-radius: 5px;
  margin-top: 20px;
  line-height: 27px;
  text-align: center;
}
.daiying54 .daiying541{
  font-weight: bold;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.daiying54 .daiying542{
  font-size: 12px;
  color: #faaf00;
  margin-top: 5px;
}
.daiying54 .daiying543{
  font-size: 12px;
  color: #666666;
  margin-top: 5px;
}
.daiying54 .daiying544{
  font-size: 12px;
  color: #666666;
  margin-top: 5px;
}
</style>